﻿using System;
using System.Collections.Generic;
using System.Text;
using Abp.Application.Services;
using Abp.Application.Services.Dto;
using Abp.AutoMapper;
using System.Linq;
using Abp.Linq.Extensions;
using Abp.Extensions;
using Sunlit.Business.Policies.Dto;
using Abp.Domain.Repositories;

namespace Sunlit.Business.Policies
{
    public class PolicyMessageAppService:AsyncCrudAppService<PolicyMessage, PolicyMessageDto,long,
        GetAllPolicyMessageInput,CreatePolicyMessageInput,UpdatePolicyMessageInput>,IPolicyMessageAppService
    {
        public PolicyMessageAppService(IRepository<PolicyMessage, long> repository):base(repository)
        {

        }
        protected override IQueryable<PolicyMessage> CreateFilteredQuery(GetAllPolicyMessageInput input)
        {
            return base.CreateFilteredQuery(input)
                .WhereIf(input.ReceiverId.HasValue, m => m.ReceiverId == input.ReceiverId)
                .WhereIf(input.PolicyId.HasValue, m => m.PolicyId == input.PolicyId);
        }
    }
}
